<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>User registration</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true&amp;key=ABQIAAAASUtmjL9mHssaCFBa-LvdsRRSxb1GItnsOFMYOopCnHv7yj9BIxTUcGWb9SIs7KvP8I-BL4YWYB7AkA" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function load()
{
	var arr = document.location.href.split(new RegExp('[?=&]'));
	for(i=1;i<arr.llength;i=i+2)
	{
		if(arr[i] == 'name')
			break;
	}
	if(i>=arr.length)
	{
		alert('配置文件有错误，无法加载地图');
		return;
	}
	
	var mapobj = parent.document.frmList[arr[i+1]];
	var para1 = 32.04184006520709;
	var para2 = 118.7841796875;
	var para3 = 12;
	if(mapobj.value!='')
	{
		arr = mapobj.value.split("/");
		if(arr.length == 3)
		{
			para1 = parseFloat(arr[0]);
			para2 = parseFloat(arr[1]);
			para3 = parseFloat(arr[2]);
		}
	}
	
	if(GBrowserIsCompatible())
	{
		var mapElem = document.getElementById("map");
		var map     = new GMap2(mapElem);
		var latlng  = new GLatLng(para1, para2);
		var zoom    = para3;
		map.addControl(new GSmallMapControl());
		map.setCenter(latlng, zoom);
		if(mapobj.value !='')
		{
			map.openInfoWindowHtml(map.getCenter(), "在这里");
		}
				var isEditMode = false;

		/*  add a marker and info window - for testing */
		map.addOverlay(new GMarker(new GLatLng(0,0)));
		GEvent.addListener(map, "click", function(overlay, latlng) {
			if(isEditMode && latlng) {
				map.openInfoWindowHtml(latlng, '在这里!');
				//返回当前地图地点所在
				//parent.setLatLngZoom(latlng.lat(), latlng.lng(), map.getZoom());
				mapobj.value = latlng.lat()+ "/" + latlng.lng()+ "/" +  map.getZoom();
				/* Back to the view mode */
				isEditMode = false;
				mapElem.className = mapElem.className.replace("edit", "view");
				button.innerHTML = "点击此处以选中店面的确切位置";
			}
		});

		/*  switch mouse cursor  */
		var button = document.getElementById("btn");
		GEvent.addDomListener(button, "click", function () {
			if (isEditMode) {
				mapElem.className = mapElem.className.replace("edit", "view");
				button.innerHTML = "点击此处以选中店面的确切位置";
			}
			else {
				mapElem.className = mapElem.className.replace("view", "edit");
				button.innerHTML = "现在在地图上选取店面的确切位置...";
			}

			isEditMode = !isEditMode;
		});
			}
}
//]]>
</script>
<style type="text/css">
/* <![CDATA[ */
#map.edit div img { cursor: crosshair; } /* overwrite the cursor on tile image  */
#map { width: 500px; height: 500px; border: 1px solid #000000;}
#btn-wrapper { width: 400px; }
#btn { cursor: pointer;font-size:12px;}
pre { margin-left: 0px; }
/* ]]> */
</style>
</head>
<body style="text-align: left; background: #eeeeee; overflow: auto" onload="load()" onunload="GUnload()">
<div id="btn-wrapper"><button id="btn" >点击此处以选中店面的确切位置</button></div>
<div id="map" class="view"></div>
</body>
</html>
